#ifndef CPP_TOOLS_TOOLKIT_HPP
#define CPP_TOOLS_TOOLKIT_HPP
#pragma once

#include <functional>
#include <utility>

namespace toolkit {

class CppDefer {
public:
  CppDefer(std::function<void()> &&defer_func)
      : defer_func_(std::move(defer_func)) {}
  ~CppDefer() {
    if (defer_func_)
      defer_func_();
  }

private:
  std::function<void()> defer_func_;
};

} // namespace toolkit

#endif